//详情参考：https://taro.redwoodjs.cn/docs/vue-entry
import {createApp} from 'vue'
import Taro from '@tarojs/taro'

import {store, useStore} from '@/stores'

import {Avatar, Button, Searchbar, Cell} from '@nutui/nutui-taro'

import {IconFont} from '@nutui/icons-vue-taro'
import '@nutui/icons-vue-taro/dist/style_iconfont.css'

import '@nutui/nutui-taro/dist/style.css'
import './app.scss'

const App = createApp({
    // 可以使用所有的 Vue 生命周期方法
    mounted() {
    },

    // 对应 onLaunch
    onLaunch() {
    },

    // 对应 onShow
    onShow(options) {
    },

    // 对应 onHide
    onHide() {
    },

    // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
})
App.use(IconFont)
App.use(Avatar)
App.use(Button)
App.use(Searchbar)
App.use(Cell)

App.use(store)

const auth = useStore('auth')
const app = useStore('app')

const token = Taro.getStorageSync('token')
if (!token) {
    auth.logout()
} else {
    app.startScreenLoading()
    setTimeout(() => {
        auth.setUserInfo({
            nickName: '林qwe',
            avatarUrl:
                'https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png'
        })
        auth.login()
        app.cancelScreenLoading()
    }, 500)
}

export default App
